<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <title>E8NET</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- bootstrap -->
<link href="/Public/Admin/css/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="/Public/Admin/css/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
<link href="/Public/Admin/css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet" />

<!-- global styles -->
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/elements.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/icons.css" />

<!-- libraries -->
<link href="/Public/Admin/css/lib/bootstrap-wysihtml5.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/lib/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/lib/font-awesome.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/lib/morris.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/popup.css" type="text/css" rel="stylesheet" />



<!-- open sans font -->
<!--<link href='http://fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css' />-->

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<link href="/Public/Libs/confirm/jquery.confirm.css" type="text/css" rel="stylesheet" />



    <!-- this page specific styles -->
    <link rel="stylesheet" href="/Public/Admin/css/compiled/chart-showcase.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="/Public/Admin/css/compiled/index.css" type="text/css" media="screen" />

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

    <!-- navbar -->
<div class="navbar navbar-inverse">
    <div class="navbar-inner">
        <button type="button" class="btn btn-navbar visible-phone" id="menu-toggler">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <a class="brand" href="index.html">
            E8网络工作室管理后台 V1.0
        </a>

        <ul class="nav pull-right">
            <li class="hidden-phone">
                <input class="search" type="text" />
            </li>


            <!-- 消息提醒 -->
            <li class="notification-dropdown hidden-phone">
                <a href="#" class="trigger">
                    <i class="icon-envelope-alt"></i>
                    <span class="count"></span>
                </a>
                <div class="pop-dialog">
                    <div class="pointer right">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div>
                    <div class="body">
                        <a href="#" class="close-icon"><i class="icon-remove-sign"></i></a>
                        <div class="messages">

                        </div>
                    </div>
                </div>
            </li>


            <!-- 个人菜单 -->
            <li class="dropdown">
                <a href="#" class="dropdown-toggle hidden-phone" data-toggle="dropdown">
                    <?php echo ($_SESSION['admin']['tname']); ?>
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="<?php echo U('Public/editPersonalInfo');?>">修改个人资料</a></li>
                    <li><a href="<?php echo U('Public/logout');?>">退出登录</a></li>
                </ul>
            </li>

            <!-- 前台首页 -->
            <li class="settings hidden-phone">
                <a href="" role="button">
                    <i class="icon-globe"></i>
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- end navbar -->
    <!-- sidebar -->
<div id="sidebar-nav">
    <ul id="dashboard-menu">

        <?php if(is_array($menu)): $i = 0; $__LIST__ = $menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$m): $mod = ($i % 2 );++$i;?><li class="<?php echo ($m["active"]); ?>">

                <?php if($m["active"] == 'active'): ?><div class="pointer">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div><?php endif; ?>

                <a <?php if($m["child"] != ''): ?>class="dropdown-toggle"<?php endif; ?>  href="<?php echo ($m["url"]); ?>">
                    <i class="<?php echo ($m["icon"]); ?>"></i>
                    <span><?php echo ($m["text"]); ?></span>
                    <?php if($m["child"] != ''): ?><i class="icon-chevron-down"></i><?php endif; ?>
                </a>

                <?php if($m["child"] != ''): ?><ul class="<?php echo ($m["active"]); ?> submenu">
                        <?php if(is_array($m["child"])): $i = 0; $__LIST__ = $m["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><li><a href="<?php echo ($c["url"]); ?>" class="<?php echo ($c["active"]); ?>"><?php echo ($c["text"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
                    </ul><?php endif; ?>
            </li><?php endforeach; endif; else: echo "" ;endif; ?>

    </ul>
</div>
<!-- end sidebar -->

	<!-- main container -->
    <div class="content">

        <div role="breadcrumb">
            <ol class="breadcrumb">
              <li><a href="<?php echo U('Dashboard/index');?>">仪表盘</a> / </li>
              <li class="active">数据表格</li>
            </ol>
        </div>

        <div class="container-fluid">
            <div id="pad-wrapper">
                <!-- App日流量统计表 -->
                <div class="row-fluid">
                    <div class="span12">
                        <div id="visitDiv">
                            <div id="visit" style="height: 400px;"></div>
                        </div>

                        <div class="btn-group toggle-inputs hidden-tablet pull-right">
                            <button class="glow left" data-input="vlast">往前十天</button>
                            <button class="glow center" data-input="vnow">最近十天</button>
                            <button class="glow right" data-input="vnext">往后十天</button>
                        </div>

                    </div>
                </div>

                <!-- App日旷课数量统计表 -->
                <div class="row-fluid section">
                    <div class="span12 chart">

                        <div id="attend" style="height: 400px;"></div>

                        <div id="attend-btn-group" class="btn-group toggle-inputs hidden-tablet pull-right">
                            <button class="glow left" data-input="alast">往前十天</button>
                            <button class="glow center" data-input="anow">最近十天</button>
                            <button class="glow right" data-input="anext">往后十天</button>
                        </div>
                    </div>
                </div>


            </div>
        </div>
    </div>
    <!-- end main container -->

    <!-- scripts for this page -->
<script src="/Public/Admin/js/wysihtml5-0.3.0.js"></script>
<script src="/Public/Admin/js/jquery-latest.js"></script>

<script src="/Public/Admin/js/bootstrap-wysihtml5-0.0.2.js"></script>
<!--<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>-->
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/jquery-ui-1.10.2.custom.min.js"></script>
<!-- knob -->
<script src="/Public/Admin/js/jquery.knob.js"></script>
<!-- flot charts -->
<script src="/Public/Admin/js/jquery.flot.js"></script>
<script src="/Public/Admin/js/jquery.flot.stack.js"></script>
<script src="/Public/Admin/js/jquery.flot.resize.js"></script>
<!-- morrisjs -->
<script src="/Public/Admin/js/raphael-min.js"></script>
<script src="/Public/Admin/js/morris.min.js"></script>
<!-- call all plugins -->
<script src="/Public/Admin/js/theme.js"></script>

<script src="/Public/Admin/js/tools.js"></script>
<script src="/Public/Libs/confirm/jquery.confirm.js"></script>

    <!-- loading modal -->
<div id="loading-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content" style="text-align:center; " >
    	<img src="/Public/Admin/img/loading.gif" style="margin:25px 0" />
    </div>
  </div>
</div>

<!-- sure modal -->
<div id="sure-modal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">警告</h4>
      </div>
      <div id="sure-modal-body" class="modal-body">
        <p>One fine body&hellip;</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn-flat gray" data-dismiss="modal">取消</button>
        <button id="btn-sure-del" type="button" class="btn-flat danger">确认删除</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script>
	
	function lshow() {
		$("#loading-modal").modal('show',{
			backdrop:false,
			keyboard:false,
		});
	}


	function lhide() {
		$("#loading-modal").modal('hide');
	}

	function sshow(url,msg) {
		$("#sure-modal-body").html(msg);
		$("#btn-sure-del").click(function(){
			$("#sure-modal").modal('hide');
			lshow();

			/**
			 * php 5.6 bug
			 * 
			 * Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
             * Warning: Cannot modify header information - headers already sent in Unknown on line 0
			 *
			 * 解决次bug 需要添加一个没有意义的参数
			 */
			$.post(url,{data:''},function(result){
                var obj = eval('(' + result + ')');
                if (obj.result == 'RESULT_OK') {
                    lhide();
                    location.reload();
                } else {
                	lhide();
                    alert(obj.msg);
                }
            });

		});

		$("#sure-modal").modal('show');
	}

</script>

    <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js">
    </script>

    <script type="text/javascript">

        // 访问量图表配置
        var visitOptions = {
            chart: { 
                type: 'spline',
                renderTo:'visit'
            },
            title: {
                text: 'App近十日流量统计表',
                x: -20 //center
            },
            subtitle: {
                text: '主要包括教师、学生日访问量',
                x: -20
            },
            xAxis: {
                categories: <?php echo ($date); ?>
            },
            yAxis: {
                title: {
                    text: '访问次数'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '次'
            },
            series: <?php echo ($visitData); ?>
        };

        // 出勤统计图表配置
        var attendOptions = {
            chart: { 
                type: 'spline',
                renderTo:'attend'
            },
            title: {
                text: 'App近十日考勤情况统计表',
                x: -20 //center
            },
            subtitle: {
                text: '主要包括所有学生的统计数据',
                x: -20
            },
            xAxis: {
                categories: <?php echo ($date); ?>
            },
            yAxis: {
                title: {
                    text: '相应考勤次数'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '次'
            },
            series: <?php echo ($attendData); ?>
        };


        $(function () {
            // 初始化图表
            var visitChart = new Highcharts.Chart(visitOptions);
            var attendChart = new Highcharts.Chart(attendOptions);

            var $buttons = $(".toggle-inputs button");
            $buttons.click(function () {
                var val = $(this).data("input");
                var url = val.substr(0,1) == 'v'?"/admin.php/Dashboard/refreshVisitChart":"/admin.php/Dashboard/refreshAttendChart";
                var type = val.substr(1);

                lshow();
                // 提交ajax请求
                $.ajax({
                    //async : true,
                    type: "post",
                    url: url,
                    dataType: "json",
                    data: {type:type},
                    timeout : 20000,
                    success: function(result) {
                        if (result.result == "RESULT_OK") {
                            // 如果是出勤图表
                            if (val.substr(0,1) == 'v') {
                                visitOptions.xAxis.categories = result.data.date;
                                visitOptions.series = result.data.data;
                                visitChart = new Highcharts.Chart(visitOptions);
                            } else {
                                attendOptions.xAxis.categories = result.data.date;
                                attendOptions.series = result.data.data;
                                attendChart = new Highcharts.Chart(attendOptions);
                            }
                            lhide();
                        } else {
                            lhide();
                            alert(result.msg);
                        }
                    },
                    error: function(request) {
                        lhide();
                        alert('提交失败');
                    }
                });
            });

        });
    </script>

    <!-- build the charts -->
    <script type="text/javascript">

        // Morris Line Chart
        // var tax_data = <?php echo ($visitData); ?>;
        // Morris.Line({
        //     element: 'visit',
        //     data: tax_data,
        //     xkey: 'period',
        //     ykeys: ['teacher', 'student'],
        //     labels: ['教师', '学生'],
        //     resize: true
        //     //dateFormat: function (x) { return new Date(x).toString(); }
        // });



        // Morris Area Chart
        // Morris.Area({
        //     element: 'attend',
        //     data: <?php echo ($attendData); ?>,
        //     xkey: 'period',
        //     ykeys: ['kk', 'cd' , 'qj' , 'zt'],
        //     labels: ['旷课', '迟到' , '请假' , '早退'],
        //     lineWidth: 2,
        //     hideHover: 'auto',
        //     lineColors: ["#999999" , "#81d5d9", "#a6e182" , "#cccccc"],
        //     resize: true
        //   });

    </script>

</body>
</html>